<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<script>

function Person(name,sex){
	this.name=name;
	this.sex=sex;	
};
Person.prototype.showName=function(){
	alert(this.name)	
};
Person.prototype.showSex=function(){
	alert(this.sex)	
};

//var p1=new Person('zs','man');
//p1.showName();
//p1.showSex();

//----------------------
function Worker(name,sex,job){
	//this->new 出来的Worker对象
	//构造函数伪装：调用父级的构造函数--为了继承属性
	Person.call(this,name,sex);
	this.job=job;	
};
//原型链     通过原型来继承父级的方法
//Worker.prototype=Person.prototype;
for(var i in Person.prototype){
	Worker.prototype[i]=Person.prototype[i];	
}
Worker.prototype.showJob=function(){
	alert(this.job)	
};
//var w1=new Worker('xx','woman','coder');
//w1.showName();
//w1.showSex();
//w1.showJob();
//alert(Person.prototype.showJob)

var p=new Person('ss','man');
var w=new Worker('xx','woman','coder')
p.showName();
p.showSex();

w.showName();
w.showSex();
w.showJob();
</script>
</body>
</html>
